package controller;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import model.Student;
import services.StudentMock;

@ManagedBean
@SessionScoped
public class StudentBean 
{
   private Student student;
   
   public StudentBean()
   {
	   student = new Student();
   }
	
   public String exists()
   {  
	  if(StudentMock.getInstance().contains(student))
	  {
		 return "student.xhtml";
	  }
	  return "newstudent.xhtml";  
   }
   
   public String create()
   {
	   StudentMock.getInstance().insert(student);
	   student = new Student();
	   return "student.xhtml";
   }
   
  public Student getStudent() {
	return student;
  }

  public void setStudent(Student student) {
	this.student = student;
  }
}


